﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DWH.Utils
{
    public class DWHConstants
    {
        //for PPBoardPullTaskBase
        public const string KEY_PAGE_ENCODING = "PageEncoding";
        public const string KEY_CONTENT_PAGE_URL_PATTERN = "ContentPageUrlPattern";
        public const string KEY_NEXT_PAGE_URL_PATTERN = "NextPageUrlPattern";
        public const string KEY_CONTENT_TARGET_ELEMENT = "ContentTargetElement";
        public const string KEY_CONTENT_TARGET_ELEMENT_ATTRIBUTE_NAME = "ContentTargetElementAttributeName";
        public const string KEY_CONTENT_TARGET_ELEMENT_ATTRIBUTE_VALUE = "ContentTargetElementAttributeValue";

        //for PPRecursiveBoardPullTask
        public const string KEY_BOARD_START_URL = "BoardStartUrl";
        public const string KEY_PAGE_NUMBER_FLAG_STRING = "PageNumberFlagString";
        public const string KEY_PAGE_HISTORY_DETECT_RESTART = "PageHistoryDetectAndRestart";
        public const string KEY_PAGE_HISTORY_DETECT_NUMBER = "PageHistoryDetectNumber";

        public const int V_PAGE_HISTORY_RESTART_DEFAULT = 1000;

        //for PPLoopUrlsBoardPullTask
        public const string KEY_LOOP_PAGELIST_URL_PATTERN = "LoopPageListUrlPattern";
        public const string KEY_LOOP_PAGELIST_NUMBER_START = "LoopPageListNumberStart";
        public const string KEY_LOOP_PAGELIST_NUMBER_END = "LoopPageListNumberEnd";

        //
        public const string KEY_WEB_ATTACHMENT_STORE_FOLDER = "WebAttachmentStoreFolder";
        public const string KEY_PAGE_TARGET_ELEMENT = "PageTargetElement";
        public const string KEY_PAGE_TARGET_ATTRIBUTE = "PageTargetElementAttribute";

        public const string KEY_TUMBLR_SITE_NAME = "TumblrSiteName";

        //Push
        public const string KEY_PUSH_TARGET_PULL_TASK_NAME = "TargetPullTaskName";
        public const string KEY_PUSH_TARGET_PULL_TASK_ASSEMBLY_FILE = "TargetPullTaskAssemblyFile";
        public const string KEY_PUSH_TARGET_PULL_TASK_TYPE_NAME = "TargetPullTaskTypeName";
        public const string KEY_PUSH_MAX_TRY_ROUND = "PushMaxTryRound";

        public const string KEY_WORKER_INSTANCE_COUNT = "WorkerInstanceCount";
        public const string KEY_WORKER_BATCH_COUNT = "WorkerBatchCount";
        public const string KEY_WORKER_TORRENT_TYPE = "TorrentType";

        public const string V_WEB_ATTACHMENT_TITLE_CONTENT_FLAG = "WebAttachment";//previously:WebAttachemnt 

        //Regex
        public const string REGEX_HTML_IMG = @"<img\b[^<>]*?\bsrc[\s\t\r\n]*=[\s\t\r\n]*[""']?[\s\t\r\n]*(?<imgUrl>[^\s\t\r\n""'<>]*)[^<>]*?/?[\s\t\r\n]*>";
        public const string REGEX_HTML_IMG_GROUP_IMGURL = "imgUrl";
        public const string REGEX_HTML_A = @"<a\b[^<>]*?\bhref[\s\t\r\n]*=[\s\t\r\n]*[""']?[\s\t\r\n]*(?<linkUrl>[^\s\t\r\n""'<>]*)[^<>]*?/?[\s\t\r\n]*>";
        //public const string REGEX_HTML_A = @"<a\b[^<>]*?\bhref[\s\t\r\n]*=[\s\t\r\n]*[""']?[\s\t\r\n]*(?<linkUrl>[^\s\t\r\n""'<>]*)[^<>]*?/?[\s\t\r\n]*>[\s\t\r\n]*(?<urlContent>.*)[\s\t\r\n]*</a>";//[\s\t\r\n]*(?<urlContent>[^\s\t\r\n<>]*)[\s\t\r\n]*</a>
        public const string REGEX_HTML_A_GROUP_LINKURL = "linkUrl";
        public const string REGEX_HTML_A_GROUP_CONTENT = "urlContent";

        public const string REGEX_HTML_CL_BFXZW = @"(?<linkUrl>http://bfxzw.com/link.php\?ref=[A-Za-z0-9]*)"; //http://bfxzw.com/link.php?ref=FkpQW5gPcR
        public const string REGEX_HTML_CL_RMDOWN = @"(?<linkUrl>http://www.rmdown.com/link.php\?hash=[A-Za-z0-9]*)"; //http://www.rmdown.com/link.php?hash=12211d60cac03a09e984c3e71c9eb5304a587d7f2e2

        public const string FLAG_TORRENT_JANDOWN = "www.jandown.com";
        public const string FLAG_TORRENT_UHOPEFIND = "uhopefind.info";

        public const string FLAG_TORRENT_BFXZW = "bfxzw.com";
        public const string FLAG_TORRENT_RMDOWN = "rmdown.com";

        public const string ATTACHMENT_TYPE_IMAGE = "Image";
        public const string ATTACHMENT_TYPE_LEGACY = "";
        public const string ATTACHMENT_TYPE_TORRENT_BFXZW = "Torrent-" + FLAG_TORRENT_BFXZW;
        public const string ATTACHMENT_TYPE_TORRENT_UHOPEFIND = "Torrent-" + FLAG_TORRENT_UHOPEFIND;
        public const string ATTACHMENT_TYPE_TORRENT_JIANDOWN = "Torrent-" + FLAG_TORRENT_JANDOWN;
        public const string ATTACHMENT_TYPE_TORRENT_RMDOWN = "Torrent-" + FLAG_TORRENT_RMDOWN;
    }
}
